package com.example.library;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;

import com.example.library.studentfragment.StudentHomeFragment;
import com.example.library.studentfragment.StudentProfileFragment;
import com.example.library.studentfragment.StudentReservationFragment;
import com.example.library.studentfragment.StudentSeatFragment;

public class StudentMainActivity extends AppCompatActivity {
    private BottomNavigationView bottomNavigationView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_student_main);
        // TODO: 绑定按钮，跳转到座位查询、预约管理、签到等功能

        // 初始化底部导航
        bottomNavigationView = findViewById(R.id.bottom_navigation);
        bottomNavigationView.setOnItemSelectedListener(item -> {
            Fragment selectedFragment = null;
            int itemId = item.getItemId();

            if (itemId == R.id.student_home) {
                selectedFragment = new StudentHomeFragment();
            } else if (itemId == R.id.student_seat) {
                selectedFragment = new StudentSeatFragment();
            } else if (itemId == R.id.student_reservation) {
                selectedFragment = new StudentReservationFragment();
            } else if (itemId == R.id.student_profile) {
                selectedFragment = new StudentProfileFragment();
            }

            if (selectedFragment != null) {
                getSupportFragmentManager()
                    .beginTransaction()
                    .replace(R.id.fragment_container, selectedFragment)
                    .commit();
                return true;
            }
            return false;
        });

        // 默认选中首页
        bottomNavigationView.setSelectedItemId(R.id.student_home);
    }
} 